package com.eat.fish_service.controller.web;


import com.eat.common_utils.R;
import com.eat.fish_service.entity.Dao.Disease;
import com.eat.fish_service.service.DiseaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LWB
 * @since 2022-05-04
 */
@RestController("webDiseaseController")
@RequestMapping("/web/disease")
@Api(tags = "web端问诊管理")
@CrossOrigin
public class DiseaseController {

    @Autowired
    private DiseaseService diseaseService;

    @ApiOperation(value = "web问诊图片，返回图片路径，添加问诊")
    @PostMapping("addDiseasePic")
    public R addDiseasePic(MultipartFile pic){
        return diseaseService.addDiseasePic(pic);
    }


    @ApiOperation(value = "web新增问诊表")
    @PostMapping ("addDisease")
    public R addDisease(@RequestBody Disease disease){
        return diseaseService.addDisease(disease);
    }

    //根据用户id查询专家问诊数据
    @ApiOperation(value = "根据用户id查询对应 未回复/已回复 的问诊数据，参数status的值为0表示未回复，1表示已回复")
    @GetMapping("getUser/{userId}/{status}")
    public R getUser(@PathVariable @ApiParam(name = "userId", value = "用户类Id", required = true) String userId,
                     @PathVariable @ApiParam(name = "status", value = "病单状态", required = true) Integer status) {
        return diseaseService.getUser(userId,status);
    }

    @ApiOperation(value = "根据用户id查找所有问诊数据")
    @GetMapping("getUserAll/{userId}")
    public R getUserAll(@PathVariable @ApiParam(name = "userId", value = "用户类Id", required = true) String userId){
        return diseaseService.getUserAll(userId);
    }

    //根据专家类id查询问诊数据
    @ApiOperation(value = "根据专家id查询对应 未回复/已回复 的问诊数据，参数status的值为0表示未回复，1表示已回复")
    @GetMapping("getExpert/{expertId}/{status}")
    public R getExpert(@PathVariable @ApiParam(name = "expertId", value = "专家类Id", required = true) String expertId,
                       @PathVariable @ApiParam(name = "status", value = "病单状态", required = true) Integer status) {
        return diseaseService.getExpert(expertId,status);
    }

    //专家回复
    @ApiOperation(value = "根据id更新病单表的专家回复")
    @PostMapping("answer/{id}")
    public R answer(@RequestBody String answer,@PathVariable String id){
        return diseaseService.answer(answer,id);
    }

    //根据疾病类id查询病单对象
    @ApiOperation(value = "根据疾病id查询病单对象")
    @GetMapping("getDiseaseVo/{diseaseId}")
    public R getDiseaseVo(@PathVariable @ApiParam(name = "diseaseId", value = "疾病类id", required = true) String diseaseId) {
        return diseaseService.getDiseaseVo(diseaseId);
    }

    //根据专家id查询病单数量
    @ApiOperation(value = "根据专家id查询 未回复/已回复 病单数量，参数status的值为0表示未回复，1表示已回复")
    @GetMapping("getDiseaseVoAmount/{expertId}/{status}")
    public R getDiseaseVoAmount(@PathVariable @ApiParam(name = "expertId", value = "专家id", required = true) String expertId,
                                @PathVariable @ApiParam(name = "status", value = "病单状态", required = true) Integer status) {
        return diseaseService.getDiseaseAmount(expertId,status);
    }
}

